#include <REGX52.H>
#include "Delay.h"
#include "LCD1602.h"
#include "IR.h"





unsigned char Num;
//unsigned int Time;
unsigned char Address;
unsigned char Command;

void main()
{
	
	LCD_Init();
	LCD_ShowString(1,1,"ADDR  CMD  NUM");
	LCD_ShowString(2,1,"00    00   000");
	IR_Init();
	
//	Int0_Init();
	
	//计算一段程序的时间(不管用)
//	Timer0_Init();
//	Timer0_SetCounter(0);	//计时前，先清零
//	Timer0_Run(1);			//开始计时
//	Delay(1);		//就计时测试 这个10ms，计时器一直在走
//	Time = Timer0_GetCounter;	//取出时间
//	LCD_ShowNum(2,1,Time,5);
	
//	Timer0_Run(0);
	
	
	
	while(1)
	{
		if(IR_GetDataFlag() || IR_GetRepeatFlag())	//如果收到数据帧或者收到连发帧
		{
			Address = IR_GetAddress();
			Command = IR_GetCommand();
			
			LCD_ShowHexNum(2,1,Address,2);
			LCD_ShowHexNum(2,7,Command,2);
		}
		if(Command == IR_VOL_MINUS)
		{
			Num--;
		}
		if(Command == IR_VOL_ADD)
		{
			Num++;
		}
		
		LCD_ShowNum(2,12,Num,3);
	}
	
}

//void Int0_Routine(void) interrupt 0		//外部中断0，中断号是0
//{
//	Num--;	//如果触发外部中断，Num++，即可测试外部中断0
//	
//}


